package com.stu.boke.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.stu.boke.entity.Notice;
import com.stu.boke.mapper.NoticeMapper;
import com.stu.boke.service.NoticeService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class NoticeServiceImpl implements NoticeService {

	
	@Autowired(required = false)
	private NoticeMapper noticeMapper;
	


	@Override
	public Notice insertSubmitNotice(Notice notice) {
		try {
			noticeMapper.insert(notice);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("创建分类失败, notice:{}, cause:{}", notice, e);
		}
		return notice;
	}


	@Override
	public void updateNotice(Notice notice) {
		try {
			noticeMapper.update(notice);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("更新分类失败, notice:{}, cause:{}", notice, e);
		}
	}

	@Override
	public void deleteNotice(Integer id) {
		try {
			noticeMapper.deleteById(id);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("删除分类失败, notice:{}, cause:{}",  e);
		}
	}


	@Override
	public Notice getNoticeById(Integer id) {
		return noticeMapper.getNoticeById(id);
	}


	@Override
    public List<Notice> listNotice(Integer status)  {
        return noticeMapper.listNotice(status);
    }

}
